package com.ryenlii.datatrans.core.tcp.run;

import com.ryenlii.datatrans.core.tcp.service.BootNettyServer;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @author zyzBoole
 * @E-mail zyzbolle@163.com
 * @date 2024/2/21 下午4:19
 */
@Component
@Slf4j
public class AsyncStartTcp {
    @Autowired
    private BootNettyServer bootNettyServer;

    @Async("asyncExecutor")
    public void start(int port, ChannelInitializer<Channel> channelInitializer) {
        try {
            bootNettyServer.bind(port, channelInitializer);
        } catch (Exception e) {
            log.error("start error", e);
        }
    }

}
